let express = require('express') // express框架
let router = express.Router()
let mysql = require('mysql')
let dbConfig = require('../db')

var connection = mysql.createConnection(dbConfig)
connection.connect()

router.get('/addOrderlist', (req, res) => {
  var sql = `insert into orders(orderNo,goodsId,goodsName,maxPrice,state,createTime,userId,userName,goodsImg,countdown,endTime) values (0,?,?,?,?,?,?,?,?,?,?)`

  var parms = [
      req.query.goodsId,
      req.query.goodsName,
      req.query.maxPrice,
      req.query.state,
      req.query.createTime,
      req.query.userId,
      req.query.userName,
      req.query.goodsImg,
      req.query.countdown,
      req.query.endTime
    ]
  console.log("a",parms)
  connection.query(sql,parms,function (err, result) {
    if (err) {
      console.log(err)
    }
    if (result) {
      console.log(result)
      res.send(result)
    }
  })
})


module.exports = router